const utils=require("./index");
const cache=require("../cache");
const config=require("../config");

module.exports={
 // 自定义拦截器拦截作用
 async Verification(req, res, next){
       if(req.headers.hasOwnProperty('token')){
             if(await cache.Get(req.url)==null){
                console.log("11111111")
                req.unparams=utils.decrypted(req.headers.token) 
                next()
             }else{
                console.log(await cache.Get(req.url))
                res.json({
                  status: config.dev.api.success,
                  cache: true,
                  data: await cache.Get(req.url)
                })
             }
           
        // console.log(utils.decrypted(req.headers.token))
        }else{
         console.log('下面的：'+req.url)
           res.json({
              status: config.dev.api.CodeError,            
              data:"缺少参数，请求头token"
       })
     }
   }
}